package com.kabuda.blog.controller;

import com.kabuda.blog.service.CategoryService;
import com.kabuda.blog.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "分类接口")
@RestController
@RequestMapping("categorys")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @ApiOperation("查找所有分类的id和name信息")
    @GetMapping
    public Result listCategory() {
        return categoryService.findAll();
    }

    @ApiOperation(value = "查找所有分类信息")
    @GetMapping("/detail")
    public Result listCategoryDetail() {
        return categoryService.findAllDetail();
    }
    @ApiOperation(value = "根据id查找分类信息")
    @GetMapping("/detail/{id}")
    public Result listCategoryDetailById(@PathVariable("id") Long id) {
        return categoryService.findAllDetailById(id);
    }
}